package com.example.baiduapi.Timmer;

import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSON;
import com.example.baiduapi.Mapper.db2Test;
import com.example.baiduapi.Mapper.mysqlMapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;

import java.time.LocalDateTime;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;


/**
 * 定时器任务
 * 详见cron表达式http://www.pppet.net/
 *
 * @author Administrator
 */
/*@Configuration
@EnableAsync
@EnableScheduling*/
public class SchedulerTask {

    @Autowired
    UserMapper userMapper;

    @Autowired
    db2Test db2Test;

    private AtomicInteger i = new AtomicInteger(0);

    public int getNumber() {
        return i.getAndIncrement();
    }
  /*  @Async
    @Scheduled(fixedDelay = 1000 * 3 ,initialDelay = 0)
    public void test1(){
        System.out.println(db2Test.test());
    }*/
/*  @Async
    @Scheduled(fixedDelay = 1000 ,initialDelay = 0)*/
    public void test2(){
    }
/*    @Async
    @Scheduled(fixedDelay = 10000 ,initialDelay = 0)
    public void test(){
        List<Chatmessageallmessage> chatmessageallmessage = userMapper.getChatmessageallmessageByTime("2023-03-08", "2023-03-09");
        System.out.println("查询的结果："+chatmessageallmessage);
    }*/
    @Async
    @Scheduled(fixedDelay = 1000*60*30 ,initialDelay = 0)
    public void testTimmer1() throws InterruptedException {

        System.out.println("计时器1"+ LocalDateTime.now());
        Thread.sleep(1000*30);
        System.out.println("1完成"+ LocalDateTime.now());
    }





}
